<template>
	<u-avatar :src="fullPath" :default-url="defaultUrl" :size="size" :shape="shape"></u-avatar>
</template>

<script lang="ts" setup>
	import { computed } from 'vue';
	import { serverUrl } from '@/config';
	
	const props = defineProps({
		src: {
			type: String,
			default: '',
		},
		defaultUrl: {
			type: String,
			default: '/static/images/common/avatar.jpg',
		},
		size: {
			type: String,
			default: '',
		},
		// 可选值square
		shape: {
			type: String,
			defalut: 'circle',
		},
	});
	
	const fullPath = computed<string>(() => {
		if (!props.src) return '';
		return props.src.includes('http') ? props.src : serverUrl + props.src;
	});
</script>
